package com.example.controller;


import com.example.base.response.Result;
import com.example.entity.Good;
import com.example.entity.GoodStock;
import com.example.entity.Params;
import com.example.service.GoodStockService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Api(tags = "商品进货管理")
@CrossOrigin
@RestController
@RequestMapping("/goodstock")
public class GoodStockController {
    @Autowired
    private GoodStockService goodstockService;


    @GetMapping("/finder")
    public Result findAll() {
        return Result.success(goodstockService.findAll());
    }


    @GetMapping("/search")
    public Result findBySearch(Params params) {
        PageInfo<Good> info = goodstockService.findBySearch(params);
        return Result.success(info);
    }

    @PostMapping
    public Result save(@RequestBody GoodStock goodStock) {
        System.out.println(goodStock);

        goodstockService.add(goodStock);


        return Result.success();
    }

    @DeleteMapping("/{id}")

    public Result delete(@PathVariable Integer id) {

        goodstockService.delete(id);
        return Result.success();
    }


}
